package pta.test0607.ArrayList入门;

import java.util.ArrayList;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        ArrayList<String> strList = new ArrayList<>();
        while (true){
            String s=sc.next();
            if (s.equals("!!end!!"))
                break;
            strList.add(s);
        }
        strList.add(0,"begin");
        strList.add("end");
        System.out.println(strList);

        String str = sc.next();

        System.out.println(strList.contains(str));
        System.out.println(strList.indexOf(str));
        System.out.println(strList.lastIndexOf(str));

        System.out.println(strList.get(0));
        strList.remove(0);
        System.out.println(strList);
        String str2 = sc.next();
        strList.set(1,str2);
        System.out.println(strList);
        String str3 = sc.next();
        ArrayList<String> strList1 = new ArrayList<String>();
        for (int i = 0; i < strList.size(); i++) {
            if (strList.get(i).contains(str3))
                strList1.add(strList.get(i));
        }
        System.out.println(strList1);
        strList.remove(str3);
        System.out.println(strList);
        strList.clear();
        System.out.println(strList+","+strList.size()+","+strList.isEmpty());
    }
}
